<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout::head('图书管理')">
    <style th:inline="text">
        body{
            background: url("[[@{/}]]img/2.jpg");
        }
    </style>
    <meta charset="UTF-8">
    <title>类别列表</title>
</head>
<body>
<div th:replace="~{layout::header}"></div>
<div class="container" style="margin-left:400px">

    <h2>类别列表</h2>

    <a  href="/category/add" th:action="@{/category/add}" >添加类别</a>
    &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<a style="text-align: center"  href="/book/list" >前往图书管理</a> </br></br></br>



    <form  th:action="@{/category/findid}" method="post">
        <a>根据类别id查询</a>      <input type="text"  name="catid" >  <input type="submit" value="搜索" />  <input type="reset" value="重填" />
    </form>
    <form th:action="@{/category/findname}" method="post">
        <a>根据类别名称查询</a>       <input type="text"  name="catname" >  <input type="submit" value="搜索" />  <input type="reset" value="重填" />
    </form>
    </form>




        <table class="table table-hover" border="1" width="1000">
            <tr>
                <th>类别id</th> <th>类别名称</th>   <th>操作</th> <th>操作</th>
            </tr>

            <tr th:each="cat : ${bookPage.getContent()}">
                <th scope="row" th:text="${cat.getId()}">id未知</th>
                <td th:text="${cat.getName()}">名称未知</td>

                <td><a th:href="@{/category/edit/{id}(id=${cat.getId()})}">编辑</a></td>
                <td><a th:href="@{/category/delete/{id}(id=${cat.getId()})}">删除</a></td>
            </tr>
        </table>

    <div>
        当前第<span th:text="${bookPage.getNumber()} + 1"></span>页 / 总<span th:text="${bookPage.getTotalPages()}"></span>页 共<span th:text="${bookPage.getTotalElements()}"></span>条记录
        <a class="btn btn-info" th:href="@{/category/list(page=1,size=${size})}">首页</a>
        <a class="btn btn-info" th:href="@{/category/list(page = ${bookPage.hasPrevious()} ? ${bookPage.getNumber()} : 1,size=${size})}">上一页</a>
        <a class="btn btn-info" th:href="@{/category/list(page = ${bookPage.hasNext()} ? ${bookPage.getNumber()} + 2 : ${bookPage.getTotalPages()},size=${size})}">下一页</a>
        <a class="btn btn-info" th:href="@{/category/list(page = ${bookPage.getTotalPages()},size=${size})}">尾页</a>
    </div>
</div>

</body>
</html>